import { defineStore } from 'pinia'
import { getUserInfo$ } from '@api/login'
export const useUserStore = defineStore('userStoreId', {
  state: () => {
    return {
      userInfo: {},
      rolePerm: '',// 角色权限
    }
  },
  getters: {},
  actions: {
    async getUserInfo(){
      const res = await getUserInfo$()
      console.log('useUserStore请求用户信息的响应结果：', res)
      const { userInfo,roles } = res.data
      this.userInfo = {...userInfo}
      this.rolePerm = roles[0].rolePerm // 角色权限，用来请求可用的菜单项
      console.log('useUserStore请求并缓存的用户信息：', this.userInfo, this.rolePerm)
      return userInfo
    }
  }
})
